package org.charles.zhifou.model.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.charles.zhifou.enums.AppTypeEnum;
import org.charles.zhifou.enums.ReviewStatusEnum;
import org.charles.zhifou.enums.ScoringStrategyEnum;
import org.charles.zhifou.model.entity.App;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 应用视图
 *
 * @author charles
 * @version 1.0
 */
@Data
public class AppVO implements Serializable {

    @Schema(description = "id")
    private Long id;

    @Schema(description = "应用名")
    private String appName;

    @Schema(description = "应用描述")
    private String appDesc;

    @Schema(description = "应用图标")
    private String appIcon;

    @Schema(description = "应用类型（0-得分类，1-测评类）")
    private AppTypeEnum appType;

    @Schema(description = "评分策略（0-自定义，1-AI）")
    private ScoringStrategyEnum scoringStrategy;

    @Schema(description = "审核状态：0-待审核, 1-通过, 2-拒绝")
    private ReviewStatusEnum reviewStatus;

    @Schema(description = "审核信息")
    private String reviewMessage;

    @Schema(description = "审核人 id")
    private Long reviewerId;

    @Schema(description = "审核时间")
    private Date reviewTime;

    @Schema(description = "创建用户 id")
    private Long userId;

    @Schema(description = "创建时间")
    private Date createTime;

    @Schema(description = "更新时间")
    private Date updateTime;

    @Schema(description = "创建用户信息")
    private UserVO user;

    /**
     * 实体类转 VO 类
     *
     * @param app
     * @return
     */
    public static AppVO entityToVo(App app) {
        if (app == null) {
            return null;
        }

        AppVO appVO = new AppVO();
        BeanUtils.copyProperties(app, appVO);

        return appVO;
    }
}
